package cn.panda.edu.service.impl;

import cn.panda.edu.dao.TeacherMapper;
import cn.panda.edu.model.Teacher;
import cn.panda.edu.model.TeacherWithBLOBs;
import cn.panda.edu.service.TeacherService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**  
 * 类描述：  
 * @author: wyd
 * @date： 2018-01-16 下午3:46:51  
 */
@Service
public class TeacherServiceImpl implements TeacherService {
	
	@Autowired
	TeacherMapper teacherMapper;
	@Override
	public PageInfo<Teacher> listTeacherByStuIdAndPage(Integer studentId, Integer pageIndex, Integer pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageIndex,pageSize);
		List<Teacher> list = teacherMapper.listTeacherByStuId(studentId);
		PageInfo<Teacher> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public int deleteByPrimaryKey(Integer teacherId) {
		// TODO Auto-generated method stub
		return teacherMapper.deleteByPrimaryKey(teacherId);
	}

	@Override
	public int insert(TeacherWithBLOBs record) {
		// TODO Auto-generated method stub
		return teacherMapper.insert(record);
	}

	@Override
	public int insertSelective(TeacherWithBLOBs record) {
		// TODO Auto-generated method stub
		return teacherMapper.insertSelective(record);
	}

	@Override
	public TeacherWithBLOBs selectByPrimaryKey(Integer teacherId) {
		// TODO Auto-generated method stub
		return teacherMapper.selectByPrimaryKey(teacherId);
	}

	@Override
	public int updateByPrimaryKeySelective(TeacherWithBLOBs record) {
		// TODO Auto-generated method stub
		return teacherMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByPrimaryKeyWithBLOBs(TeacherWithBLOBs record) {
		// TODO Auto-generated method stub
		return teacherMapper.updateByPrimaryKeyWithBLOBs(record);
	}

	@Override
	public int updateByPrimaryKey(Teacher record) {
		// TODO Auto-generated method stub
		return teacherMapper.updateByPrimaryKey(record);
	}

	@Override
	public PageInfo<Teacher> selectByPageAndSelective(Integer teacherId, String teacherRealname, Integer pageIndex,
			Integer pageSize) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String,Object>();
		map.put("teacherId", teacherId);
		map.put("teacherRealname", teacherRealname);
		PageHelper.startPage(pageIndex,pageSize);
		List<Teacher> tList = teacherMapper.selectByPageAndSelective(map);
		PageInfo<Teacher> pageInfo = new PageInfo<Teacher>(tList);
		return pageInfo;
	}

	@Override
	public int updatePermissionByPrimaryKey(Integer roleId, Integer teacherId) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String,Object>();
		map.put("roleId", roleId);
		map.put("teacherId", teacherId);
		return teacherMapper.updatePermissionByPrimaryKey(map);
	}

	@Override
	public Teacher manageLogin(Integer teacherId, String teacherPwd) {
		// TODO Auto-generated method stub
		Map<String, Object> map = new HashMap<String,Object>();
		map.put("teacherPassword", teacherPwd);
		map.put("teacherId", teacherId);
		return teacherMapper.manageLogin(map);
	}
	/* (non-Javadoc)
	 * @see cn.panda.edu.serviceapi.TeacherService#teacherLogin(java.lang.Integer, java.lang.String)
	 */
	@Override
	public Teacher teacherLogin(Integer teacherId, String pwd) {
		// TODO Auto-generated method stub
		return teacherMapper.teacherLogin(teacherId, pwd);
	}

	/* (non-Javadoc)
	 * @see cn.panda.edu.serviceapi.TeacherService#teacherModfiyPwd(java.lang.Integer, java.lang.String)
	 */
	@Override
	public int teacherModfiyPwd(Integer teacherId, String pwd) {
		// TODO Auto-generated method stub
		return teacherMapper.teacherModfiyPwd(teacherId, pwd);
	}

}
